package com.action.mvc.auth.context;

import com.action.mvc.auth.entity.User;

/**
 * Created by Wuxiang on 2017/4/24.
 */
public class UserContext {
    private User user;

    private static ThreadLocal<UserContext> threadLocal = new ThreadLocal<>();

    private UserContext(User user) {
        this.user = user;
    }

    public static void setCurrent(User user){
        threadLocal.set(new UserContext(user));
    }

    public static UserContext getCurrent(){
        return threadLocal.get();
    }

    public User getUser(){
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
}
